
<?php header("Cache-Control: no-cache, must-revalidate");
 
session_start();

session_register("lin");
session_register("pagi");
session_register("lineasxpagi");

 $nombre=$HTTP_GET_VARS['nombre'];

 
if (!isset($krd)) $krd = $_POST['krd']; else $krd = $_GET['krd'];
$ruta_raiz="../..";
if(!isset($_SESSION['dependencia']))	include "$ruta_raiz/rec_session.php";
require_once("$ruta_raiz/include/db/ConnectionHandler.php");
?>
<!--<link href="<?=$ruta_raiz?>/auditoria/css/ventana-modal.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<?=$ruta_raiz?>/auditoria/js/ventana-modal.js"></script>-->
<?
$db = new ConnectionHandler($ruta_raiz);
$db->conn->SetFetchMode(ADODB_FETCH_ASSOC);	 

?>

<?
$error = 0;

if (isset($b_com))
{
   switch ($b_com)
   {
      case "<--":
         $pagi=$pagi-$lineasxpagi;
         if ($pagi<0)
             $pagi=0;
         mostrar_compr();
         break;
      case "-->":
         $pagi=$pagi+$lineasxpagi;
         mostrar_compr();
         break;

      case "-->|":
         $pagi=floor(count($mat_sol) / $lineasxpagi);
         $pagi=$pagi*$lineasxpagi;
         mostrar_compr();
         break;

      case "|<--":
         $pagi=0;
         mostrar_compr();
	 break;
      case "Nit":
	$pagi=0;
	usort($mat_sol, "comparar_nit");
 	 mostrar_compr();
      break;
     case "Nombre":
	$pagi=0;
	usort($mat_sol, "comparar_nombre");
 	 mostrar_compr();
      break;	
   }
}

  
   
   $sel_comp=" $sel_comp 1=1 ";
	include('$ruta_raiz/adodb/adodb.inc.php'); # Carga el codigo de ADOdb   
   $consulta = "SELECT a.sgd_oem_nit AS NIT, a.sgd_oem_oempresa AS EMPRESA, a.sgd_oem_telefono AS TELEFONO, a.sgd_oem_sigla AS SIGLA, a.sgd_oem_direccion AS DIRECCION, a.sgd_oem_rep_legal AS REPRESENTANTE   
   FROM sgd_oem_oempresas a WHERE 1=1 AND  $sel_comp AND a.sgd_oem_oempresa like '%$nombre%' ";
   $ADODB_COUNTRECS = true; 
   $rs = $db->conn->Execute($consulta);
	$conteo=$rs->RowCount();
	$cad=$rs->RecordCount();
	
   
   if($conteo==0){
   		echo "<TABLE ALIGN='CENTER' valign='center'>";
		   ?><tr style="background-color: #E3E8EC" ><br /><br /><br />
		   <td ><small><b>Coincidencias NO Encontradas</small></td></b>
		    <script>
		  		close();
			</script> 
		   </table>
		   <?}
   if ($conteo==1)
      {
       ?> <script>
	   	 opener.document.form1.txt_nuir_empr.value ='<?echo $mat_sol[0]['nit'];?>';
         opener.document.form1.nombre<?= $lin; ?>.value ='<?echo $mat_sol[0]['nombre'];?>';
         opener.document.form1.txt_estado.value='1';
        
    	 </script>
      <? }
 

?>
<html>
<head>
<body>
<link rel="stylesheet" href="../../estilos/orfeo.css">
<script>
function solic(c,d,e,f,g,h,i)
{
		
		
		opener.document.form1.txt_nuir_emp.value=c.value;
		opener.document.form1.txt_name.value=d.value;
		opener.document.form1.txt_tel1.value=e.value;
		opener.document.form1.txt_sigla.value=f.value;
		opener.document.form1.txt_dir.value=g.value;
        opener.document.form1.txt_dir.value.toUpperCase( );
		opener.document.form1.txt_dig.value=h.value;
		opener.document.form1.txt_namer.value=i.value;
		 window.close();
		 //alert(c.value);
         //alert(d.value);
	  //	document.form1.txt_sigla.value = 
	   //window.document.form1.txt_name_ciu.value=d.value;
	   //document.getElementById('txt_nuir_ciu').value = 'hola'
	//opener.document.form1.txt_nuir_ciu=33333;
	 // 	alert(window.opener.document.form1.txt_name_ciu.value=d.value);
	  	//	document.getElementById.txt_sigla.value = d.value;
  	    
}
</script>

<table border="0" width="100%" cellspacing="0" cellpadding="0" height="100%">
<tr><td width="100%"  height="100%">
<?php $titulo="Nits "; ?>
<table border="0" width="100%" align=center cellspacing="0" cellpadding="0" height="100%">
  <tr><td align="center">
       <table border="0" align=center cellspacing="0" cellpadding="0">

       <form action="nit.php" method="post" name="banco">
        <tr><td>
	  <table border="1" cellspacing="0" cellpadding="0"  >
          <tr style="background-color: #006699" onmouseover="this.style.backgroundColor = '#006699'"  >
         <td></td>
		  <th nowrap>
		  
		  <input type='submit' value='Nit' id='docu' name='b_com' style='background-color: #006699; height: 18; font-size: 12px; font-color: #ffffff; border-style: solid; border-width: 0' >
		
	<th nowrap>
	<input type='submit' value='Nombre' id='docu' name='b_com' style='background-color: #006699; height: 18; font-size: 9px; font-color: white; border-style: solid; border-width: 0'> </th></tr>
        <?
              $h=0;
              
	while(!$rs->EOF)
     	      {
            ?>
<tr style="background-color: #E3E8EC" onmouseover="this.style.backgroundColor = '#FFFFCC'" onmouseout="this.style.backgroundColor = '#E3E8EC'" >
<?

 			  $simbolos = array(".", "-",",");
			  $rs->fields["NIT"] = str_replace($simbolos, "", $rs->fields["NIT"]);
			  $longitud=strlen($rs->fields["NIT"]);
			  $cadena=$rs->fields["NIT"];
			  $total_sin_dig=$rs->fields["NIT"];
			  $total_sin_dig= substr ($total_sin_dig, 0, strlen($total_sin_dig) - 1);

	$rs->fields["EMPRESA"]= str_replace("??","&oacute;",$rs->fields["EMPRESA"]);		
    echo "
	<td>
	<input type=radio name=x onclick='solic(this.form.c$h, this.form.objeto$h, this.form.d$h, this.form.e$h, this.form.f$h, this.form.g$h, this.form.i$h)'></td>
	
	<input type=hidden name='c$h' value='".$total_sin_dig."'>
	<input type=hidden name='d$h' value='".$rs->fields["TELEFONO"]."'>
	<input type=hidden name='e$h' value='".$rs->fields["SIGLA"]."'>
	<input type=hidden name='f$h' value='".$rs->fields["DIRECCION"]."'>
	
	<input type=hidden name='objeto$h' id='objeto$h' value='".$rs->fields["EMPRESA"]."'>
	<input type=hidden name='g$h' value='".$cadena[$longitud-1]."'>
	<input type=hidden name='i$h' value='".$rs->fields["REPRESENTANTE"]."'>
	
	<td nowrap><small>".$total_sin_dig."<b> - ".$cadena[$longitud-1]."</td><td><small>".$rs->fields["EMPRESA"]."</small></td>";	$rs->MoveNext();
	$h++;	
	
	
       
		   }
        ?>
          </td></tr><td>     <?echo "<small>Registros: <b><font color=#FF0000>".$conteo."</small></font>";?></td>
           </table>
           <input type='submit' value='|<--' id='in_bco' name='b_com' style='background-color: #738EB5; height: 18; font-size: 10px; font-weight: bold; color: ffffff; border-style: solid; border-width: 1'>
           <input type='submit' value='<--' id='ant_bcor' name='b_com' style='background-color: #738EB5; height: 18; font-size: 10px; font-weight: bold; color: ffffff; border-style: solid; border-width: 1'>
           <input type='submit' value='-->' id='av_bco' name='b_com' style='background-color: #738EB5; height: 18; font-size: 10px; font-weight: bold; color: ffffff; border-style: solid; border-width: 1'>
           <input type='submit' value='-->|' id='f_bco' name='b_com' style='background-color: #738EB5; height: 18; font-size: 10px; font-weight: bold; color: ffffff; border-style: solid; border-width: 1'>
         </td></tr>
        </form>
       </table>
      <?php include('../configuracion/tablainferior.php');?>
    </td>
  </tr>
</table>
</td></tr>
</table>
</body>
</html>

